package mytest;


public class Test4 {

	static int count=0;
	static int input[]={1,3,5,9};
	static int a[]=new int[10000];
	static int size=0,lastsize=0;
	static int gap=Integer.MAX_VALUE;
	static int result[]=new int[10000];
	static void solve(int sum,int n)
	{
		count++;
		if(n<0)return;
		if(Math.abs(sum-input[n])<gap)
		{
			gap=Math.abs(sum-input[n]);
			System.arraycopy(a, 0, result, 0, size);
			result[size]=input[n];
			lastsize=size+1;
			/*
			for(int i=0;i<size;i++)
			{
				System.out.print(a[i]+"+");
			}
			System.out.println(n);
			*/
		}
		a[size++]=input[n];
		solve(sum-input[n],n-1);
		size--;
		solve(sum,n-1);
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		
		
//		solve(7,input.length-1);
//		//System.out.println(gap);
//		for(int i=0;i<lastsize;i++)System.out.print(result[i]+" ");
//		
//		System.out.println();
//		
//		System.out.println("count:"+count);
		
		int i=-1;
		int k=(i<<1)^(i>>31);
		
		System.out.println(Integer.toBinaryString(i<<1)+","+Integer.toBinaryString(i>>31));
	}

}
